package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Yzz;
import com.ruoyi.system.service.IYzzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 育种值Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/yzz")
public class YzzController extends BaseController
{
    @Autowired
    private IYzzService yzzService;

    /**
     * 查询育种值列表
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:list')")
    @GetMapping("/list")
    public TableDataInfo list(Yzz yzz)
    {
        startPage();
        List<Yzz> list = yzzService.selectYzzList(yzz);
        return getDataTable(list);
    }

    /**
     * 导出育种值列表
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:export')")
    @Log(title = "育种值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yzz yzz)
    {
        List<Yzz> list = yzzService.selectYzzList(yzz);
        ExcelUtil<Yzz> util = new ExcelUtil<Yzz>(Yzz.class);
        util.exportExcel(response, list, "育种值数据");
    }

    /**
     * 获取育种值详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:query')")
    @GetMapping(value = "/{官方编号}")
    public AjaxResult getInfo(@PathVariable("官方编号") String 官方编号)
    {
        return success(yzzService.selectYzzBy官方编号(官方编号));
    }

    /**
     * 新增育种值
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:add')")
    @Log(title = "育种值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Yzz yzz)
    {
        return toAjax(yzzService.insertYzz(yzz));
    }

    /**
     * 修改育种值
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:edit')")
    @Log(title = "育种值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Yzz yzz)
    {
        return toAjax(yzzService.updateYzz(yzz));
    }

    /**
     * 删除育种值
     */
    @PreAuthorize("@ss.hasPermi('system:yzz:remove')")
    @Log(title = "育种值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{官方编号s}")
    public AjaxResult remove(@PathVariable String[] 官方编号s)
    {
        return toAjax(yzzService.deleteYzzBy官方编号s(官方编号s));
    }
}
